<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="main_layout::html_header(~{::link}, ~{::style})">
	<link rel="stylesheet" th:href="@{/lib/DataTables/1.10.15/datatables.min.css}" />
	<link rel="stylesheet" th:href="@{/lib/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.min.css}" />
	<link rel="stylesheet" th:href="@{/lib/bootstrap-fileinput/4.4.7/css/fileinput.min.css}" />
	<link rel="stylesheet" th:href="@{/lib/bootstrap-fileinput/4.4.7/themes/explorer/theme.min.css}" />
	
	<style type="text/css">
	.info-box-content {
		margin-left: 10px;
	}
	.timeline-item {
		background-color: #ecf0f5 !important;
	}
	.preview_files .kv-file-content {
		display: none;
	}
	.preview_files .file-drop-zone-title {
		padding: 10px;
	}
	</style>
</head>
 
<body class="hold-transition skin-blue fixed">
<div class="wrapper">

<header class="main-header" th:replace="main_layout::header">
</header>

<aside class="main-sidebar">
	<section class="sidebar" th:replace="main_layout::menu">
	</section>
</aside>

<div class="content-wrapper">
<section class="content-header">
	<h1><a th:href="@{/index}">首页</a><small><a th:href="@{/} + ${url}" th:text="${title}"></a></small></h1>
</section>
	
<section class="content">

<div class="box box-info">
<div class="box-header">
	<form class="form-inline" id="search_form" method="post">
		<div class="form-group">
			<label for="name">合同编号：</label>
			<input type="text" class="form-control" name="no" th:value="${no}" style="width: 150px" />
		</div>
		<div class="form-group">
			<label for="jfWtr">委托人：</label>
			<input type="text" class="form-control" name="jfWtr" th:value="${jfWtr}" style="width: 100px" />
		</div>
		
		<div class="form-group">
			<label for="organizationName">录入人：</label>
			<input type="text" class="form-control" name="user" th:value="${user}" style="width: 150px" />
		</div>
		<div class="form-group">  
			<button type="button" class="btn btn-primary" onclick="$('#search_form').submit();">查询</button>
			<button type="button" class="btn btn-info" onclick="stamp_all();">一键盖章</button>
		</div>
	</form> 
</div>

<div class="box-body">
<table id="contract_table" class="table table-hover table-bordered">
    <thead>
    <tr>
    	<th><input type="checkbox" id="cont_check_all"></th>
    	<th>合同编号</th>
        <th>地区</th>
        <th>公司</th>
        <th>业务名称</th>
        <th>一次分期</th>
        <th>宏金保</th>
        <th>委托人</th>
        <th>甲方联系人</th>
        <th>总金额</th>
        <th>当前进度</th>
        <th>录入人</th>
        <th>录入时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="row : ${rows}">
    	<td th:utext="${row.id}"></td>
    	<td th:utext="${row.no}"></td>
    	<td th:utext="${row.area}"></td>
    	<td th:utext="${row.company}"></td>
    	<td th:utext="${row.ywmc}"></td>
    	<td th:utext="${row.ycfq}"></td>
    	<td th:utext="${row.isHjb}"></td>
    	<td th:utext="${row.jfWtr}"></td>
    	<td th:utext="${row.jfLxr}"></td>
    	<td th:utext="${row.fyhj}"></td>
    	<td th:utext="${row.nodeInfo}"></td>
    	<td th:utext="${row.username}"></td>
    	<td th:utext="${row.createTime}"></td>
    	<td th:utext="${row.option}"></td>
    </tr>
    </tbody>
</table>

</div>
</div>

</section>
</div>
  
<footer class="main-footer" th:replace="main_layout::footer">
</footer>


<aside class="control-sidebar control-sidebar-light">
    
</aside>

<div class="control-sidebar-bg" ></div>

</div>

<div th:replace="fragment/audit_template::process">
</div>

<div th:replace="fragment/audit_template::apply_audit(${url})"></div>

<!-- 盖章选择对话框 S -->
<div class="modal fade" id="stamp_modal" role="dialog">
<div class="modal-dialog">
 <div class="modal-content">
 
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	<h4 class="modal-title">选择盖章方式</h4>
</div>

<div class="modal-body">
<div class="row" style="padding: 0px 20px">

<form action="#" class="form-horizontal" id="stamp_form">
	<input type="hidden" name="stamp_id" id="stamp_id" />
	<div class="form-group">
		<label for="gzfs" class="col-sm-2 control-label">盖章方式</label>
		<div class="col-sm-10">
			<label class="radio-inline">
				<input type="radio" name="gzfs" value="rg" checked="checked"> 人工
			</label>
			<label class="radio-inline">
				<input type="radio" name="gzfs" value="dz"> 电子
			</label>
		</div>
	</div>
</form>
   
</div>
</div>

<div class="modal-footer">
	<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	<button type="button" class="btn btn-primary" onclick="stamp_cont_submit()">下一步</button>
</div>

</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--盖章选择对话框 E -->

<!--上传对话框 S -->
<div class="modal fade" id="put_modal" role="dialog">
<div class="modal-dialog modal-lg" style="width: calc(100% - 200px)">
 <div class="modal-content">
 
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	<h4 class="modal-title">上传合同资料</h4>
</div>

<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<form action="#" class="form-horizontal" id="put_form">
	<input type="hidden" name="put_id" id="put_id" />
	<div class="form-group">
		<div class="col-sm-12" style="text-align: left">
    			<input id="cont_pics" name="upload_pic" type="file" multiple>
		</div>
	</div>
	<div class="form-group">
		<div class="col-sm-12" style="text-align: left">
    			<input id="cont_docs" name="upload_doc" type="file" multiple>
		</div>
	</div>
	<hr />
	<div class="form-group">
		<label for="value" class="col-sm-1 control-label">审核人</label>
		<div class="col-sm-5">
			<select name="put_oper_user" id="put_oper_user" class="form-control" data-rule-required="true">
			</select>
		</div>
		<div class="col-sm-6">
			<button type="button" class="btn btn-primary pull-right" onclick="put_submit()">提交法务部复审</button>
			<button type="button" class="btn btn-default pull-right" data-dismiss="modal" style="margin-right: 10px">取消 </button>
		</div>

	</div>
</form>
</div> 
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--上传对话框 E -->
<script th:src="@{/pageoffice.js}" id="po_js_main"></script>
<script th:src="@{/lib/DataTables/1.10.15/datatables.min.js}"></script>
<script th:src="@{/lib/DataTables/datatables.config.js}"></script>
<script th:src="@{/lib/moment/2.18.1/moment.min.js}"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script th:src="@{/lib/bootstrap-fileinput/4.4.7/js/plugins/sortable.min.js}"></script>
<script th:src="@{/lib/bootstrap-fileinput/4.4.7/js/fileinput.min.js}"></script>
<script th:src="@{/lib/bootstrap-fileinput/4.4.7/js/locales/zh.js}"></script>
<script th:src="@{/lib/bootstrap-fileinput/4.4.7/themes/explorer/theme.min.js}"></script>

<script>
var contract_table;

function cont_view(id) {
	POBrowser.openWindowModeless("[[@{/contract/view/}]]" + id, 'width=1200px;height=800px;');
}

function print_cont(id) {
	POBrowser.openWindowModeless("[[@{/contract/print/}]]" + id, 'width=1200px;height=800px;');
}

function refresh(url) {
	location.href = "[[@{/}]]" + url;
}
function edit_cont(id) {
	location.href = "[[@{/contract/edit/}]]" + id;
}
function stamp_all() {
	if($('.cont_check:checked').length == 0) {
		$.dialog.alert("请选择要盖章的合同");
		return;
	}
	var ids = [];
	$('.cont_check:checked').each(function(){
		ids.push($(this).val());
	});
	$.dialog.confirm("确认盖章已选择合同？", function(){
		$.post("[[@{/audit/stamp/rgall}]]", {ids: ids}, function(ret){
			if(ret.success) {
				location.href = "[[@{/audit/stamp/}]]"
			} else {
				alert(ret.message);
			}
		}, "json");
	});
}
//申请盖章
function stamp_cont(id) {
	$("#stamp_id").val(id);
	$("#stamp_modal").modal({backdrop:'static', keyboard: false});
}
function stamp_cont_submit() {
	var id = $("#stamp_id").val();
	var gzfs = $("input[name='gzfs']:checked").val();
	if(gzfs == 'rg') {
		$.dialog.confirm("确认已经人工盖章？", function(){
			$.post("[[@{/audit/stamp/rg}]]", {id: id}, function(ret){
				if(ret.success) {
					location.href = "[[@{/audit/stamp/}]]"
				} else {
					alert(ret.message);
				}
			}, "json");
		})	
	} else {
		$("#stamp_modal").modal("hide");
		POBrowser.openWindowModeless("[[@{/audit/stamp/}]]" + id, 'width=1200px;height=800px;');
	}
}

function cancel_cont(id) {
	$.dialog.confirm("确认作废该合同吗？", function(){
		$.post("[[@{/contract/cancel}]]", {id: id}, function(ret){
			if(ret.success) {
				location.reload(true);
			} else {
				alert(ret.message);
			}
		}, "json");
	})	
}

$(function() {
	//点击表头复选框执行动作
	$("#cont_check_all").on('click', function() {
		$(".cont_check").prop('checked', $("#cont_check_all").is(':checked'));
	});
	
	contract_table = $('#contract_table').DataTable({
		paging: false,
		select: false,
		order: [12, 'desc'],
        columnDefs: [
        	{targets: 0,  orderable: false, width: "10px", render: function(data, type, full, meta) {
				return '<input type="checkbox" class="cont_check" value="' + data + '">';
			}},
        	{targets: 1, width: "140px", render:function(data, type, full, meta ) {
        		return 	"<a href = 'javascript:;' onclick='cont_view(" + full[0] + ")'>" + data + "</a>";
        	}},
        	{targets:2, orderable: false, width: "40px", render: function(data, type, full, meta ) {
        		var area = '';
        		switch(data) {
        		case 'A':
        			area = '上海';
        			break;
        		case 'B':
        			area = '苏州';
        			break;
        		case 'C':
        			area = '成都';
        			break;
        		}
            	return	area;
            }},
            {targets:3, orderable: false, width: "40px"},
        	{targets:5, orderable: false, width: "60px", render: function(data, type, full, meta ) {
            	return	data == 'O' ? "一次" : "分期";
            }},
        	{targets: 6, orderable: false, width: "50px", render:function(data, type, full, meta ) {
        		return 	data ? "是" : "否";
        	}},
        	{targets:9,  width: "50px", render: function(data, type, full, meta ) {
            	return	data == 0 ? "" : data;	
            }},
        	{targets:10,  orderable: false, render: function(data, type, full, meta ) {
        		return 	"<a style='white-space:pre' href = 'javascript:;' onclick='show_process(" + full[0] + ")'>" + data + "</a>";		
            }},
        	{targets:11,  width: "50px"},
            {targets: -2,  width: "120px",  className: "align_right", render: function (data, type, full, meta ) {
				return data ? moment(data).format("YYYY-MM-DD HH:mm:ss") : '';
			}},
        	{targets: -1, orderable: false,  width: "150px",  className: "align_center"}
        ]
    });
});
</script>
</body>
</html>
